<script setup lang="ts">
import { isEmpty } from 'lodash';
import { computed } from 'vue'

interface Props {
  prefix?: string
  name: string
  color?: string
}

const props = withDefaults(defineProps<Props>(), {
  prefix: 'icon'
})

const symbolId = computed(() => `#${props.prefix}-${props.name}`)
</script>

<template>
  <svg aria-hidden="true">
    <use v-if="isEmpty(color)" :xlink:href="symbolId" />
    <use v-else :xlink:href="symbolId" :fill="color" />
  </svg>
</template>

<style scoped>
svg {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
</style>